/*
 * @Description: 表单
 * @Author: bxsdhx
 * @Date: 2024-12-02 23:24:54
 * @LastEditTime: 2025-10-25 22:25:49
 * Copyright (C) 2024 bxsdhx. All rights reserved.
 */
import { type Ref, ref } from "vue";
/**
 * @description: 创建一个可重置的表单
 * @param {T} form 表单实际内容
 * @return {*}
 */
export default function <T>(form: T): [Ref<T>, (newForm?: T) => void] {
  const data = ref<T>();
  const reset = function (newForm?: T) {
    data.value = JSON.parse(JSON.stringify(newForm || form || null));
  };
  reset();
  return [data as Ref<T>, reset];
}
